package com.jiangjiang.eshop.schedule.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiangjiang.eshop.schedule.convert.ScheduleOrderPickingItemConvert;
import com.jiangjiang.eshop.schedule.dao.ScheduleOrderPickingItemMapper;
import com.jiangjiang.eshop.schedule.domain.ScheduleOrderPickingItemEntity;
import com.jiangjiang.eshop.schedule.dto.ScheduleOrderPickingItemDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName ScheduleOrderPickingItemService
 * @Description TODO
 * @Author jhw
 * @Date 2021/8/31 6:55
 * @Version 1.0
 **/
@Service
public class ScheduleOrderPickingItemService extends ServiceImpl<ScheduleOrderPickingItemMapper, ScheduleOrderPickingItemEntity> {

    @Autowired
    private ScheduleOrderPickingItemConvert scheduleOrderPickingItemConvert;

    /**
     * 根据订单id和订单条目id查询拣货条目
     * @param orderInfoId 订单id
     * @param orderItemId 订单条目id
     * @return
     */
    public  List<ScheduleOrderPickingItemDTO> listByOrderItemId(Long orderInfoId, Long orderItemId) {
        LambdaQueryWrapper<ScheduleOrderPickingItemEntity> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(ScheduleOrderPickingItemEntity::getOrderInfoId, orderInfoId)
                .eq(ScheduleOrderPickingItemEntity::getOrderItemId,orderItemId);
        return  scheduleOrderPickingItemConvert.convertEntities2DTOList(this.list(wrapper));
    }
}
